﻿namespace Idenmpotency
{
    /// <summary>
    /// 接口：幂等性请求处理器
    /// </summary>
    public interface IIdenmptencyRequestHandler
    {

        /// <summary>
        /// 前置检查
        /// </summary>
        /// <param name="request"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public Task<bool> PreCheckHandleAsync(IIdenmpotencyRequest request, CancellationToken token = default);

        /// <summary>
        /// 首次请求处理
        /// </summary>
        /// <param name="context"></param>
        /// <param name="next"></param>
        /// <returns></returns>
        public Task FirstRequestHandleAsync(IIdenmpotencyRequest request, CancellationToken token = default);

        /// <summary>
        /// 重复请求处理
        /// </summary>
        /// <param name="context"></param>
        /// <param name="next"></param>
        /// <returns></returns>
        public Task ReiteratedRequestHandleAsync(IIdenmpotencyRequest request, CancellationToken token = default);
    }
}
